<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        /* 
            instanceof可以判断一个对象是否是某个构造函数的实例
        */
       var arr1 = [];
       var arr2 = ['aa','bb'];
       var arr3 = "abc";//是基础数据类型，不是属于对象，所以不属于Object
       var arr4 = new String("abc");

        //判断arr1和arr2是数组吗
        console.log(arr1 instanceof Array);
        console.log(arr2 instanceof Array);
        console.log(arr3 instanceof Array);

        function Car(make, model, year) {
            this.make = make;
            this.model = model;
            this.year = year;
       }

       function Dog(name, age, color) {
            this.name = name;
            this.age = age;
            this.color = color;
       }

       const auto = new Car('Honda', 'Accord', 1998);
       const haha = new Dog('haha', '2', '白色');

       console.log(auto instanceof Car);
       console.log(auto instanceof Dog);//false
       console.log(haha instanceof Dog);
       console.log(haha instanceof Car);//false
       
       console.log(auto instanceof Object);
       console.log(haha instanceof Object);
       console.log(arr1 instanceof Object);
       console.log(arr2 instanceof Object);
       console.log(arr3 instanceof Object); // var arr3 = "abc" false 
       console.log(arr4 instanceof Object);
    </script>
</head>
<body>
    
</body>
</html>